#include<iostream>
#include<algorithm>
#include<stack>
#include<string>
using namespace std;

bool is_true(string s, stack<char>stk)
{
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '(' || s[i] == '[' || s[i] == '{') {
			stk.push(s[i]);
		}
		else {
			if (s[i] == stk.top()) {
				stk.pop();
			}
			else  return false;
		}
	}
	return true;
}

int main()
{
	string s;
	cin >> s;
	stack<char>stk;
	cout << is_true(s, stk);
	return 0;
}
